package com.xx.job.service.system.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xx.job.controller.dto.PageDTO;
import com.xx.job.entity.system.SysContent;
import com.xx.job.mapper.SysContentMapper;
import com.xx.job.service.system.SysContentService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author liangcy
 * @since 2021-01-14
 */
@Service
public class SysContentServiceImpl extends ServiceImpl<SysContentMapper, SysContent> implements SysContentService {

    @Autowired
    private SysContentMapper sysContentMapper;

    @Override
    public int add(SysContent sysContent) {
        return sysContentMapper.insert(sysContent);
    }

    @Override
    public int delete(Long id) {
        return sysContentMapper.deleteById(id);
    }

    @Override
    public int update(SysContent sysContent) {
        return sysContentMapper.updateById(sysContent);
    }

    @Override
    public SysContent select(Long id) {
        return sysContentMapper.selectById(id);
    }

    @Override
    public IPage<SysContent> selectPage(PageDTO pageDTO, SysContent sysContent) {
        IPage<SysContent> page = new Page<>(pageDTO.getPageIndex(),pageDTO.getPageSize());
        QueryWrapper<SysContent> wrapper = new QueryWrapper<>();
        // TODO 参数过滤
        return sysContentMapper.selectPage(page,wrapper);
    }
}
